<input id="status" name="status" type="hidden" value="{$params.status}"/>
<input id="p" name="p" type="hidden" value="{$p}" />
<table class="table table-bordered">
    <thead>
      <tr>
        <th width="6%">资讯ID</th>
        <th width="8%">标题</th>
        <th>作者</th>
        <th>资讯类型</th>
          <th>资讯性质</th>
        <th width="8%" >资讯来源</th>
        <th>主频道</th>
        <th>子频道</th>
        <th>是否精华</th>
        <th width="9%">创建时间</th>
        <th width="9%">发布时间</th>
        <th>状态</th>
          <th>PV</th>
          <th>昨日UV</th>
          <th>评论数</th>
        <th width="11%">操作</th>
      </tr>
    </thead>
    <tbody>
      <volist name="article" id="vo" key="k">
        <tr>
          <td>{$vo.article_id}</td>
          <td>{$vo.article_title}</td>
          <td>{$vo.author}</td>
            <td><if condition="$vo['article_attribute'] eq 1">图文<else/>视频</if></td>
          <td><if condition="$vo['type'] eq 1">原创<else/>转载</if></td>
          <td><if condition="$vo['type'] neq 1">{$vo.from_name}<else/>车来车往</if></td>
          <td>{$cate[$vo['category_id']]['category_title']}</td>
          <td>{$cate[$vo['child_id']]['category_title']}</td>
          <td><if condition="$vo.is_top eq 1">是<else/>否</if></td>
            <td> {$vo.create_time|date="Y-m-d H:i",###}</td>
          <td style="text-align: center;">
              <if condition="$vo['status'] eq 1">
                  {$vo.publish_time|date="Y-m-d H:i",###}
              <elseif condition="$vo['status'] eq 3"/>
                  {$vo.cron_time|date="Y-m-d H:i",###}
              <else />
                  --
              </if>
          </td>
          <td>
          	<if condition="$vo.status eq 0">
          	删除
			<elseif condition="$vo.status eq 1"/>
			已发布
            <elseif condition="$vo.status eq 2"/>
            未发布
            <elseif condition="$vo.status eq 3"/>
            预发布
			</if>
          </td>
            <td>{$vo.pv}</td>
            <td>{$vo.uv}</td>
            <td><a target="_blank" href="/comment/article/article_id/{$vo.article_id}">{$vo.comment}</a></td>
          <td>
              <if condition="$vo['status'] neq 0">
              <a target="_blank" href="/Article/add/id/{$vo.article_id}">编辑</a> |
              <a href="javascript:;" onclick="openwin('/Article/show/id/{$vo.article_id}');">预览</a>
              <if condition="$vo['status'] eq 1">
                  | <a href="javascript:;" onclick="publish({$vo.article_id},2);">下线</a>
                  <else/>
                  | <a href="javascript:;" onclick="publish({$vo.article_id},1);">发布</a>
              </if>
              <if condition="$vo['status'] neq 3 && $vo['status'] neq 1 && $vo['status'] neq 0">
                  | <a href="javascript:;" onclick="del({$vo.article_id});">删除</a>
              </if>
                  <else />
                  <a target="_blank" href="/Article/add/id/{$vo.article_id}">查看</a>
              </if>
          </td>
      	</tr>
      </volist>
    </tbody>
  </table>
  <div class="pageFaye"><div class="pager">{$page}</div><div class="clear"></div></div>

<div class="deparHover" style="height: 200px;">
    <h4>资讯采集预发布</h4>
    <label>
        发布时间：<input type="text" id="publish_time" name="publish_time" value="" readonly="" placeholder="发布时间">
    </label>
    <input type="hidden" id="article_id" value="" />
    <div class="deparBtn">
        <input type="button" value="确定" class="deparQue" id="submitPublish">
        <input type="button" value="取消" id="closePublis">
    </div>
</div>


<script>
    $(function(){
        $('#closePublis').click(function(){
            $('.deparHover').hide();
            $('#article_id').val('');
            $('#publish_time').val('');
        });
        $('#submitPublish').click(function(){
            var article_id = $('#article_id').val();
            var publish_time = $('#publish_time').val();
            if (!article_id) {
                return false;
            }
            if (!publish_time) {
                alert('请选择发布时间!');
                return false;
            }
            $.post('/Article/articleCronPublish', {article_id:article_id, publish_time:publish_time}, function (data) {
                if (data.code == '200') {
                    alert(data.msg);
                    $('.deparHover').hide();
                    $('#article_id').val('');
                    $('#publish_time').val('');
                    searchList();
                } else{
                    alert(data.msg);
                }
            }, 'json');

        });
    });

    function showPublisBox(id){
        $('.deparHover').show();
        $('#article_id').val(id);
    }

	function publish(id,status){
	    var msg = '';
	    if(status == 2){
            msg = '下线';
        }else{
	        msg = '发布';
        }
		if(confirm('您确定要把此资讯'+msg+'吗?')){
			$.post('/Article/changeStatus',{id:id,status:status}, function(data){
				if(data.code == 200){
					btn_alert('您的资讯已经保存成功！');
					searchList();
				}else{
					shibai_alert('保存失败请重试');
				}
			},'json');
		}
	}

    function del(id){
        if(confirm('您确定要删除此资讯吗?')){
            $.post('/Article/changeStatus',{id:id,status:0}, function(data){
                if(data.code == 200){
                    btn_alert('您的资讯已经删除成功！');
                    searchList();
                }else{
                    shibai_alert('删除失败请重试');
                }
            },'json');
        }
    }

    function openwin(url) {
        var a = document.createElement("a");
        a.setAttribute("href", url);
        a.setAttribute("target", "_blank");
        a.setAttribute("id", "openwin");
        document.body.appendChild(a);
        a.click();
    }

</script>